<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateReportTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
{
    $table = $this->table('think_report', [
        'id' => 'id',
        'signed' => true,
        'auto_increment' => true
    ]);

    $table
        ->addColumn('reporter_id', 'integer', ['null' => false, 'comment' => '举报人ID'])
        ->addColumn('reported_id', 'integer', ['null' => false, 'comment' => '被举报人ID'])
        ->addColumn('reason', 'string', ['limit' => 255, 'null' => false, 'comment' => '举报原因'])
        ->addColumn('details', 'text', ['null' => true, 'comment' => '举报详情'])
        ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '处理状态：0未处理，1已处理'])
        ->addColumn('create_time', 'datetime', ['null' => false, 'comment' => '创建时间'])
        ->addColumn('update_time', 'datetime', ['null' => false, 'comment' => '更新时间'])
        ->addColumn('images', 'json', [
                'comment' => '举报图片资料',
                'null'=>true
            ])
        ->addIndex(['reporter_id', 'reported_id'], ['unique' => false, 'name' => 'idx_reporter_reported'])
        ->create();
}
}
